		function getImportStatus()
		{
			$.ajax({
				  url: '/import/getImportResult',
				  type: 'POST',
				  dataType: 'json',
				  success: function(data) {
					  if (data.status == "Waiting")
					  {
						  
					  }
					  if (data.status == "Processing")
					  {
						  var thehtml = data.status + ', Lines Imported: ' + data.linesImported;
						  $('div #importResult').html('');
						  $('<div/>', {html: thehtml}).appendTo('div #importResult');
					  }
					  if (data.status == "ReportEnded")
					  {
						  var thehtml = data.status + ', Lines Imported: ' + data.linesImported + '<br/>' + data.errors;
						  $('div #importResult').html('');
						  $('<div/>', {html: thehtml}).appendTo('div #importResult');
						  
					  }
				  }
			});
		}


		$("#userChoice").submit(function() {
		    
		    $.ajax({
				  url: '/api/v2/getTop10Step3Deals',
				  type: 'POST',
				  dataType: 'json',
				  data: $('#userChoice').serializeArray(),
				  success: function(data) {
					  $('div #reportContent').html('');
					  
					  if (data.deals)
					  {  
						  var items = [];
						  items.push('<h1>set 1</h1>');
						  items.push('<tr><th>Talk</th><th>Messages</th><th>Data</th><th>Operator</th><th>Phone</th><th>Price</th><th>Contract <br/> Length</th><th>Upfront <br/> Cost</th><th>Calculated <br/> Cost</th><th>Rank</th><th>Deep Link</th></tr>');
							
						  $.each(data.deals, function(key, val) {
						    items.push('<tr id="' + key + '"><td>' + transformToString(val.talk) + '</td><td>' + transformToString(val.message) + '</td><td>' + transformToString(val.data) + '</td><td>' + val.operator + '</td><td>' + val.phoneModel + '</td><td>' + transformToString(val.price) + '</td><td>' + val.contractLength + '</td><td>' + transformToString(val.upfrontCost) + '</td><td>' + val.calcCost + '</td><td>' + val.rank + '</td><td>' + val.deepLink+ '</td><td>' + val.resultType+ '</td></tr>');
						  });					  
						
						  $('<table/>', {
						    'class': 'my-new-list',
						    html: items.join('')
						  }).appendTo('div #reportContent');
					  }
					  
					  if (!data.secondChoiseDeals)
						  return;
					  var items2 = [];
					  items2.push('<h1>set 2</h1>');
					  items2.push('<tr><th>Talk</th><th>Messages</th><th>Data</th><th>Operator</th><th>Phone</th><th>Price</th><th>Contract <br/> Length</th><th>Upfront <br/> Cost</th><th>Calculated <br/> Cost</th><th>Rank</th><th>Deep Link</th></tr>');
						
					  $.each(data.secondChoiseDeals, function(key, val) {
						  items2.push('<tr id="' + key + '"><td>' + transformToString(val.talk) + '</td><td>' + transformToString(val.message) + '</td><td>' + transformToString(val.data) + '</td><td>' + val.operator + '</td><td>' + val.phoneModel + '</td><td>' + transformToString(val.price) + '</td><td>' + val.contractLength + '</td><td>' + transformToString(val.upfrontCost) + '</td><td>' + val.calcCost + '</td><td>' + val.rank + '</td><td>' + val.deepLink+ '</td></tr>');
					  });					  
					
					  $('<table/>', {
					    'class': 'my-new-list',
					    html: items2.join('')
					  }).appendTo('div #reportContent');
				  }
		    });
		    
		    
		    return false;
		});
		
		$("#userChoice2").submit(function() {
		    
		    $.ajax({
				  url: '/api/v2/getStep1and2Deals',
				  type: 'POST',
				  dataType: 'json',
				  data: $('#userChoice2').serializeArray(),
				  success: function(data) {
					  $('div #reportContent').html('');
					  
					  if (data.deals)
					  {  
						  var items = [];
						  items.push('<h1>set 1</h1>');
						  items.push('<tr><th>Talk</th><th>Messages</th><th>Data</th><th>Operator</th><th>Phone</th><th>Price</th><th>Contract <br/> Length</th><th>Upfront <br/> Cost</th><th>Calculated <br/> Cost</th><th>Rank</th><th>Deep Link</th></tr>');
							
						  $.each(data.deals, function(key, val) {
						    items.push('<tr id="' + key + '"><td>' + transformToString(val.talk) + '</td><td>' + transformToString(val.message) + '</td><td>' + transformToString(val.data) + '</td><td>' + val.operator + '</td><td>' + val.phoneModel + '</td><td>' + transformToString(val.price) + '</td><td>' + val.contractLength + '</td><td>' + transformToString(val.upfrontCost) + '</td><td>' + val.calcCost + '</td><td>' + val.rank + '</td><td>' + val.deepLink+ '</td><td>' + val.resultType+ '</td></tr>');
						  });					  
						
						  $('<table/>', {
						    'class': 'my-new-list',
						    html: items.join('')
						  }).appendTo('div #reportContent');
					  }
					  
					  if (!data.secondChoiseDeals)
						  return;
					  var items2 = [];
					  items2.push('<h1>set 2</h1>');
					  items2.push('<tr><th>Talk</th><th>Messages</th><th>Data</th><th>Operator</th><th>Phone</th><th>Price</th><th>Contract <br/> Length</th><th>Upfront <br/> Cost</th><th>Calculated <br/> Cost</th><th>Rank</th><th>Deep Link</th></tr>');
						
					  $.each(data.secondChoiseDeals, function(key, val) {
						  items2.push('<tr id="' + key + '"><td>' + transformToString(val.talk) + '</td><td>' + transformToString(val.message) + '</td><td>' + transformToString(val.data) + '</td><td>' + val.operator + '</td><td>' + val.phoneModel + '</td><td>' + transformToString(val.price) + '</td><td>' + val.contractLength + '</td><td>' + transformToString(val.upfrontCost) + '</td><td>' + val.calcCost + '</td><td>' + val.rank + '</td><td>' + val.deepLink+ '</td></tr>');
					  });					  
					
					  $('<table/>', {
					    'class': 'my-new-list',
					    html: items2.join('')
					  }).appendTo('div #reportContent');
				  }
		    });
		    
		    
		    return false;
		});
		
		function transformToString(value)
		{
			if (value == "-1")
				return "Unlimited";
			if (value == "-2")
				return "Free";
			return value;
		}
		
		
